package DAL;

import DBUtil.SQLUtil;

public class Login {
	
	//检测用户登录信息是否合法，合法这返回true
	public boolean checkLogin(String uName,String uPwd)
	{
		String sqlCmd="select count(*) from user where userId=? and userPwd=?";//要执行的查询T-SQL命令
		Object[] objList=new Object[2];//对象数组，用来作为？参数的容器
		objList[0]=uName;
		objList[1]=uPwd;
		String result=SQLUtil.excuteScalar(sqlCmd,objList).toString();//执行带参数查询
		if(result.equals("1"))
		{
			return true;
		}
		else {
			return false;
		}
	}
	
	//根据用户Id获取用户名
	public String  getName(String uId)
	{
		String sqlCmd="select userName from user where userId='"+uId+"'";
		String result=SQLUtil.excuteScalar(sqlCmd, null).toString();
		return result;
	}
	
	//获取用户等级（角色）信息
	public String  getSysLevel(String uId)
	{
		String sqlCmd="select roleId from user where userId='"+uId+"'";
		String result=SQLUtil.excuteScalar(sqlCmd, null).toString();
		return result;
	}
}
